<?php
namespace app\admin\model;

use think\Model;
use think\Log;
use think\Db;
use think\Exception;

class Comment extends Model
{

    /**
     * 获取文章列表
     * @author wcy
     * @version 2017年6月26日11:12:16
     */
      public function commentList($search,$start,$length){
          try{
              $where=" 1=1";
              if(!empty($search)){
                  $where=$where." and title like '%$search%'";
              }
              $data=Db::table("comment")->where($where)->limit($start,$length)->select();
              $count=Db::table("comment")->where($where)->count();
              return array("data"=>$data,"count"=>$count);
          }catch (Exception $e){
              Log::record($e->getMessage());
              return false;
          }
      }
    /**
     * 修改文章状态
     * @author wcy
     * @version 2017年7月11日09:45:55
     */
    public function editComment($id,$data){
        try{
            $res=Db::table("comment")->where("id=$id")->update($data);
            return $res;
        }catch (Exception $e){
            Log::record($e->getMessage());
            return false;
        }
    }
}